<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: fit-content;
            margin:  0 auto;
        }
    </style>
</head>

<body>
        <div>
            <label for="email">邮箱：</label><input type="text" id="email">
            <button id="btn">提交</button>
        </div>
    <script>
        var email = document.querySelector('#email')
        var btn = document.querySelector('#btn')
        var str;   // 以5到11位字母数字开头 @ 163等邮箱 . com等后缀结尾
        var reg = /^[0-9a-zA-Z]{5,11}@(163|qq|126)\.(com|cn|sina|net)$/
        btn.onclick = function(){
            str = email.value
           if(reg.test(str)){
                alert('验证成功')
           }else{
               alert('请输入正确的邮箱地址')
           }
        }
        
        
    </script>
</body>
</html>